package com.pl.dailycollection.util;

import java.time.LocalDateTime;

/**
 * @ClassName DataUtil
 * @Description: 日期工具类
 * @Author pl
 * @Date 2019/11/22
 * @Version V1.0
 **/
public class DataUtil {

    /**  
    * @MethodName: getCurrentTime
    * @Description: 获取当前时间
    * @Param: getCurrentTime
    * @Return: java.time.LocalDateTime
    * @Author: pl
    * @Date: 16:42
    **/
    public LocalDateTime getCurrentTime(){
       // LocalDateTime now = LocalDateTime.now();
        return LocalDateTime.now();
    }

    /**
    * @MethodName: getAppointedDay
    * @Description: 获取指定日期
    * @Param: getAppointedDay
    * @Return: java.time.LocalDateTime
    * @Author: pl
    * @Date: 16:57
    **/
    public LocalDateTime getAppointedDay(int year,int month,int day,int hour,int minute,int second){
       // LocalDateTime appointedDay = LocalDateTime.of(year, month, day, hour, minute, second);
        return  LocalDateTime.of(year, month, day, hour, minute, second);
    }

    /**
     * @MethodName: getAppointedDay
     * @Description: 加减日期
     * @Param: getAppointedDay
     * @Return: java.time.LocalDateTime
     * @Author: pl
     * @Date: 16:57
     **/
    public LocalDateTime pluasOrMinus(LocalDateTime originalTime,Boolean flag) {
        //flag = true: plus : minus;
        if (flag){
        //加时间
            return originalTime.plusYears(1).plusMonths(2).plusDays(3).plusHours(5).plusMinutes(45).plusSeconds(32);
        }else {
            return originalTime.minusYears(1).minusMonths(2).minusDays(3).minusHours(5).minusMinutes(45).minusSeconds(32);
        }
    }


}
